package com.meitianhui.convenitenbuy.module.home.http;

import com.meitianhui.convenitenbuy.base.BaseResponse;
import com.meitianhui.convenitenbuy.http.RetrofitHelper;
import com.meitianhui.convenitenbuy.main.model.bean.SignInfo;
import com.meitianhui.convenitenbuy.module.home.model.bean.AreaCode;
import com.meitianhui.convenitenbuy.module.home.model.bean.BannerBean;
import com.meitianhui.convenitenbuy.module.home.model.bean.FightGroupAddress;
import com.meitianhui.convenitenbuy.module.home.model.bean.FreePaper;
import com.meitianhui.convenitenbuy.module.home.model.bean.GoodsInfoDetail;
import com.meitianhui.convenitenbuy.module.home.model.bean.HomeGoodsInfo;
import com.meitianhui.convenitenbuy.module.home.model.bean.MemberInfo;
import com.meitianhui.convenitenbuy.module.home.model.bean.OfficialStore;
import com.meitianhui.convenitenbuy.module.home.model.bean.RecommendGoods;
import com.meitianhui.convenitenbuy.module.home.model.bean.SetUpOrderBean;
import com.meitianhui.convenitenbuy.module.home.model.bean.ZeroBuyImage;
import com.meitianhui.convenitenbuy.module.order.model.bean.EmptyInfo;
import com.meitianhui.convenitenbuy.module.wallet.model.RechargeBackInfoBean;
import com.meitianhui.convenitenbuy.util.RxUtils;

import retrofit2.http.Query;
import rx.Observable;

/**
 * Created by Administrator on 2017/11/1.
 */

public class HomeApiDataSource implements HomeApi {

    private static volatile HomeApiDataSource instance = null;

    private HomeApiDataSource() {
    }

    public static HomeApiDataSource getInstance() {
        if (instance == null) {
            synchronized (HomeApiDataSource.class) {
                if (instance == null) {
                    instance = new HomeApiDataSource();
                }
            }
        }
        return instance;
    }

    @Override
    public Observable<BaseResponse<AreaCode>> getAreaCode(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 0).getAreaCode(appToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<BannerBean>> getBanner(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 0).getBanner(appToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<RecommendGoods>> getRecommendGoods(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 0).getRecommendGoods(appToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<HomeGoodsInfo>> getEdinburgh(@Query("app_token") String appToken, @Query("service") String service, @Query("page") String page, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 0).getEdinburgh(appToken, service, page, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<SignInfo>> signInToday(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 1).signInToday(userToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<OfficialStore>> getOfficialStore(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 1).getOfficialStore(userToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<EmptyInfo>> officialStorePost(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 1).officialStorePost(userToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<EmptyInfo>> freeCouponPay(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 1).freeCouponPay(userToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<OfficialStore>> settingDefaultStore(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 1).settingDefaultStore(userToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<GoodsInfoDetail>> getGoodsInfoDetail(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 1).getGoodsInfoDetail(appToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<GoodsInfoDetail>> getJoinGoodsInfoDetail(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 1).getJoinGoodsInfoDetail(appToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }


    @Override
    public Observable<BaseResponse<FightGroupAddress>> getFightGroupAddress(@Query("user_token") String userToken, @Query("service") String service, @Query("page") String page, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 1).getFightGroupAddress(userToken, service, page, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<FreePaper>> getFreePaper(@Query("app_token") String appToken, @Query("service") String service, @Query("page") String page, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 1).getFreePaper(appToken, service, page, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<MemberInfo>> getMemberInfo(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 1).getMemberInfo(userToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<OfficialStore>> getStoreInfo(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 1).getStoreInfo(userToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<EmptyInfo>> collectStore(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 0).collectStore(appToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<EmptyInfo>> payIntegration(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 1).payIntegration(userToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<EmptyInfo>> userIntegrationPay(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 1).userIntegrationPay(userToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<SetUpOrderBean>> setUpOrder(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 1).setUpOrder(userToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<RechargeBackInfoBean>> payMoneyHuiGuo(@Query("user_token") String userToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 1).payMoneyHuiGuo(userToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

    @Override
    public Observable<BaseResponse<ZeroBuyImage>> getZeroBuyImage(@Query("app_token") String appToken, @Query("service") String service, @Query("params") String params) {
        return RetrofitHelper.createApi(HomeApi.class, true, 0).getZeroBuyImage(appToken, service, params).compose(RxUtils.rxSchedulerHelper());
    }

}
